* July 5, 2021
version 16.1

*************
* Load Data *
*************

use ../Data/raw_wave1and2

*************************
* Randomized Treatments *
*************************

* Did US pass laws to reduce emissions and increase energy prices
gen byte laws = cond(strpos(action,"passed new laws")==0,0,1)
drop action

* Characteristics of the laws
replace emiss=0 if laws==0 // if no laws, no change in emissions
replace energy=0 if laws==0 // if no laws, no change in energy prices

* Indicator for five levels of action (emissions, energy)
gen axn5 = .
replace axn5 = 0 if laws==0
replace axn5 = 1 if laws==1 & emiss==5 & energy==10
replace axn5 = 2 if laws==1 & emiss==5 & energy==4
replace axn5 = 3 if laws==1 & emiss==25 & energy==10
replace axn5 = 4 if laws==1 & emiss==25 & energy==4
label define axn5 0 "None" 1 "5%, 10%" 2 "5% 4%" 3 "25% 10%" 4 "25% 4%" 
label values axn5 axn5
label var axn5 "T: Action (emiss, energy) - 5 cat"

* Indicator for three levels of action, ignoring change in energy prices
recode axn5 0=0 1/2=1 3/4=2, gen(axn3)
label define axn3 0 "None" 1 "5% emiss" 2 "25% emiss"
label values axn3 axn3
label var axn3 "T: Action (emiss, energy) - 3 cat"

* Shaming condition
tab shame, miss
gen byte shamed = cond(shame=="",0,1)
label var shamed "T: Shaming"
drop shame

********************
* Attention checks *
********************

gen byte joined = 1  // US joined paris

// Q76 Before continuing, we need to make sure you read this page carefully.
// In the passage you read, what did the U.S. government announce?
// o	It would join the Paris Agreement  (1) 
// o	It would not join the Paris Agreement  (2) 
// o	Not sure  (3) 
// o	No information given  (4) 
gen byte attn_joined = 0
replace attn_joined = 1 if joined==1 & q76==1 // would join
replace attn_joined = 1 if joined==0 & q76==2 // would not join
tab attn_joined wave, col miss

// Q93 In the passage you read, did the government pledge to reduce U.S. emissions of carbon dioxide?
// o	Yes  (1) 
// o	No  (2) 
// o	Not sure  (3) 
// o	No information given  (4) 
gen byte attn_pledged = 0
replace attn_pledged = 1 if joined==1 & q93==1 // pledged to reduce emission
replace attn_pledged = 1 if joined==0 & q93==2 // did not pledge to reduce
tab attn_pledged wave, col miss

// Q78 In the passage you read, the government pledged to reduce U.S. emissions of carbon dioxide by ...
// o	5%  (1) 
// o	15%  (2) 
// o	25%  (3) 
// o	35%  (4) 
// o	None of the above  (5) 
gen byte attn_pledgepct = 0 if joined==1  // only asked if joined, otw miss
replace attn_pledgepct = 1 if q78==3      // if joined, always pledged 25%
tab attn_pledgepct wave, col miss
tab attn_pledgepct wave, col

// Q80 Before continuing, we need to make sure you read this page carefully.
// In the passage you read, did the U.S. government pass new laws to reduce carbon dioxide emissions?
// o	Yes  (1) 
// o	No  (2) 
// o	Not sure  (3) 
// o	No information given  (4) 
gen byte attn_laws = 0
replace attn_laws = 1 if laws==1 & q80==1 // passed new laws
replace attn_laws = 1 if laws==0 & q80==2 // did not pass new laws
tab attn_laws wave, col miss

// If action = ${e://Field/action_yes}: Q85 Experts agreed that the new laws would increase U.S. energy prices by ...
// o	4%  (1) 
// o	6%  (2) 
// o	8%  (3) 
// o	10%  (4) 
// o	None of the above  (5) 
// If action = ${e://Field/action_no}: Q81 In the passage you read, did the government take steps to affect U.S. energy prices?
// o	Yes  (1) 
// o	No  (2) 
// o	Not sure  (3) 
// o	No information given  (4) 
gen byte attn_energy = 0
replace attn_energy = 1 if laws==1 & energy==4 & q85==1  // increase by 4%
replace attn_energy = 1 if laws==1 & energy==10 & q85==4 // increase by 10%
replace attn_energy = 1 if laws==0 & q81==2  // took no steps to affect prices
tab attn_energy wave, col miss

// If action = ${e://Field/action_yes}: Q84 Experts agreed that the new laws would reduce U.S. carbon emissions by ...
// o	5%  (1) 
// o	15%  (2) 
// o	25%  (3) 
// o	35%  (4) 
// o	None of the above  (5) 
// If action = ${e://Field/action_no}: Q83 In the passage you read, did the government take steps to affect U.S. carbon emissions?
// o	Yes  (1) 
// o	No  (2) 
// o	Not sure  (3) 
// o	No information given  (4) 
gen byte attn_emiss = 0
replace attn_emiss = 1 if laws==1 & emiss==5 & q84==1 // cut by 5%
replace attn_emiss = 1 if laws==1 & emiss==25 & q84==3 // cut by 25%
replace attn_emiss = 1 if laws==0 & q83==2 // no steps to affect emissions
tab attn_emiss wave, col miss

// Q89 Before we continue, we need to make sure you read this page carefully.
// In the passage you read, did other countries criticize the United States?
// o	Yes  (1) 
// o	No  (2) 
// o	Not sure  (3) 
// o	No information given  (4) 
// Q90 In the passage you read, what did other countries say about the United States? Answer as completely and as accurately as possible.
gen byte attn_shame = 0 if shamed == 1 // only asked if shamed
replace attn_shame = 1 if q89==1 // other countries shamed the US
tab attn_shame wave, col miss
tab attn_shame wave, col

* Overall score on attention checks
egen attn_correct = rowtotal(attn_joined attn_pledged attn_pledgepct ///
   attn_laws attn_energy attn_emiss attn_shame) // Number correct
egen attn_asked = rownonmiss(attn_joined attn_pledged attn_pledgepct ///
   attn_laws attn_energy attn_emiss attn_shame) // Number asked
gen attn_pct = attn_correct*100/attn_asked // percent correct
gen byte attn_passed = cond(attn_pct >= 80, 1, 0)
label var attn_passed "Attn: Passed"

bysort wave: tab attn_pct attn_asked // percent correct vs number asked

su attn_*

* cleanup
drop q76 q93 q78 q80 q85 q81 q84 q83 q89 q90 attn_joined attn_pledged ///
   attn_pledgepct attn_laws attn_energy attn_emiss attn_shame attn_correct ///
	attn_asked attn_pct laws emiss energy joined

*********************************
* Pretreatment Covariate: Party *
*********************************

// pid_1 Generally speaking, do you think of yourself as a ... 
// o	Republican  (1) 
// o	Democrat  (2) 
// o	Independent  (3) 
// o	Another party, please specify  (4) __
// o	No preference  (5) 
//
// Display This Question:
// If Generally speaking, do you think of yourself as a ...  = Republican
// Or Generally speaking, do you think of yourself as a ...  = Democrat
//
// pid_2 Would you call yourself a ...
// o	Strong ${pid_1/ChoiceGroup/SelectedChoices}  (1) 
// o	Not very strong ${pid_1/ChoiceGroup/SelectedChoices}  (2) 
//
// Display This Question:
// If Generally speaking, do you think of yourself as a ...  != Republican
// And Generally speaking, do you think of yourself as a ...  != Democrat
//
// pid_3 Do you think of yourself as closer to the ...
// o	Republican Party  (1) 
// o	Democratic Party  (2) 
// o	Neither party  (3) 

recode pid_1 2=1 1=3 *=2, gen(pid3) // other ==> indep
label define pid3 1 "Dem" 2 "Ind" 3 "Rep"
label values pid3 pid3
label var pid3 "P: Party 3 cats (1,2,3)"

gen pid7 = .
replace pid7 = 1 if pid3==1 & pid_2==1 // strong dem
replace pid7 = 2 if pid3==1 & pid_2==2 // not strong dem
replace pid7 = 3 if pid3==2 & pid_3==2 // lean dem
replace pid7 = 4 if pid3==2 & pid_3==3 // doesn't lean
replace pid7 = 5 if pid3==2 & pid_3==1 // lean rep
replace pid7 = 6 if pid3==3 & pid_2==2 // not strong rep
replace pid7 = 7 if pid3==3 & pid_2==1 // strong rep
label define pid7 1 "Str Dem" 2 "Weak Dem" 3 "Lean Dem" 4 "Don't Lean" ///
   5 "Lean Rep" 6 "Weak Rep" 7 "Str Rep"
label values pid7 pid7
tab pid7 pid3, miss col
drop pid_1 pid_2 pid_3 pid_1_text
label var pid7 "P: Party 7 cats (1,2,3,4,5,6,7)"

***********************************
* Pretreatment Covariates: CC, FF *
***********************************

// Q67 There is much discussion about whether humans are causing climate change. Which of the following statements comes closest to your own opinion?
// o	Humans are causing climate change  (1) 
// o	Humans are not causing climate change  (2) 
// o	Don't know  (3) 
recode q67 1=1 2/3=0, gen(hc2)
label define hc2 0 "No/DK" 1 "Yes"
label values hc2 hc2
label var hc2 "C: Humans causing? (2 cat)"
drop q67

// Q75 In your opinion, should the U.S. government pass new laws that would require Americans to reduce their use of fossil fuels, including coal, oil, and gas? 
// o	Yes  (4) 
// o	No  (5) 
recode q75 4=1 5=0, gen(ff2)
label define ff2 0 "No" 1 "Yes"
label values ff2 ff2
label var ff2 "C: Regulate FF? (Binary)"
tab ff2, miss
drop q75

********************************
* Dependent Variable: Approval *
********************************

// Q94 Taking into account all the decisions the U.S. government made in the passage you read, would you approve or disapprove of what U.S. government did overall?
// o	Approve strongly  (1) 
// o	Approve somewhat  (2) 
// o	Neither approve nor disapprove  (3) 
// o	Disapprove somewhat  (4) 
// o	Disapprove strongly  (5) 
gen a_overall = q94
recode a_overall 5=0 4=25 3=50 2=75 1=100
recode a_overall 0/50=0 75/100=100, gen(a_overall2) // binary
tab a_overall a_overall2, miss
label var a_overall "A: Approve of decisions overall"
label var a_overall2 "A: Approve of decisions overall (binary)"
drop q94

********************
* Demographic Vars *
********************

// malefemale 
// Are you male or female?
// o	Male  (1) 
// o	Female  (0) 
rename malefemale male
label var male "D: Male"

// race What racial or ethnic group best describes you?
// o	White  (1) 
// o	Black or African American  (2) 
// o	Hispanic or Latino  (3) 
// o	Asian or Asian American  (4) 
// o	Native American  (5) 
// o	Middle Eastern  (6) 
// o	Mixed Race  (7) 
// o	Some other race – Type in race  (8) 
recode race 1=1 *=0, gen(white)
label var white "D: White"
recode race 2=1 *=0, gen(black)
label var black "D: Black"
drop race race_text

// age_sel Please enter your age on your last birthday.
// o	18  (1), 19  (2) , o	99 +  (82) 
gen age = age_sel + 17
label var age "D: Age"
drop age_sel

// educ What is the highest level of school you have completed?
// o	Did not graduate from high school  (1) 
// o	High school graduate  (2) 
// o	Some college, but no degree (yet)  (3) 
// o	2-year college degree  (4) 
// o	4-year college degree  (5) 
// o	Postgraduate degree (MA, MBA, MD, JD, PhD, etc)  (6) 
recode educ 1/2=1 3/4=2 5=3 6=4, gen(ed4)
label define ed4 1 "HS or less" 2 "Some college" 3 "College deg" 4 "Grad deg"
label values ed4 ed4
label var ed4 "D: Education (4 cat)"
tab ed4, miss
drop educ

// state_sel In what state do you currently reside?
// o	Alabama  (1) 
// o	Alaska  (51) 
// o	Arizona  (2) 
// o	Arkansas  (3) 
// o	California  (4) 
// o	Colorado  (5) 
// o	Connecticut  (6) 
// o	Delaware  (7) 
// o	District of Columbia  (8) 
// o	Florida  (9) 
// o	Georgia  (10) 
// o	Hawaii  (52) 
// o	Idaho  (11) 
// o	Illinois  (12) 
// o	Indiana  (13) 
// o	Iowa  (14) 
// o	Kansas  (15) 
// o	Kentucky  (16) 
// o	Louisiana  (17) 
// o	Maine  (18) 
// o	Maryland  (19) 
// o	Massachusetts  (20) 
// o	Michigan  (21) 
// o	Minnesota  (22) 
// o	Mississippi  (23) 
// o	Missouri  (24) 
// o	Montana  (25) 
// o	Nebraska  (26) 
// o	Nevada  (27) 
// o	New Hampshire  (28) 
// o	New Jersey  (29) 
// o	New Mexico  (30) 
// o	New York  (31) 
// o	North Carolina  (32) 
// o	North Dakota  (33) 
// o	Ohio  (34) 
// o	Oklahoma  (35) 
// o	Oregon  (36) 
// o	Pennsylvania  (37) 
// o	Puerto Rico  (50) 
// o	Rhode Island  (38) 
// o	South Carolina  (39) 
// o	South Dakota  (40) 
// o	Tennessee  (41) 
// o	Texas  (42) 
// o	Utah  (43) 
// o	Vermont  (44) 
// o	Virginia  (45) 
// o	Washington  (46) 
// o	West Virginia  (47) 
// o	Wisconsin  (48) 
// o	Wyoming  (49) 
// o	I do not reside in the United States  (53) 

* state and region of united states
rename state_sel state
label var state "D: State of Residence"
gen region = .
quietly {
replace region = 1 if state == 6 // Northeast (Connecticut)
replace region = 1 if state == 18 // Northeast (Maine)
replace region = 1 if state == 20 // Northeast (Massachusetts)
replace region = 1 if state == 28 // Northeast (New Hampshire)
replace region = 1 if state == 29 // Northeast (New Jersey)
replace region = 1 if state == 31 // Northeast (New York)
replace region = 1 if state == 37 // Northeast (Pennsylvania)
replace region = 1 if state == 38 // Northeast (Rhode Island)
replace region = 1 if state == 44 // Northeast (Vermont)
replace region = 2 if state == 12 // Midwest (Illinois)
replace region = 2 if state == 13 // Midwest (Indiana)
replace region = 2 if state == 14 // Midwest (Iowa)
replace region = 2 if state == 15 // Midwest (Kansas)
replace region = 2 if state == 21 // Midwest (Michigan)
replace region = 2 if state == 22 // Midwest (Minnesota)
replace region = 2 if state == 24 // Midwest (Missouri)
replace region = 2 if state == 26 // Midwest (Nebraska)
replace region = 2 if state == 33 // Midwest (North Dakota)
replace region = 2 if state == 34 // Midwest (Ohio)
replace region = 2 if state == 40 // Midwest (South Dakota)
replace region = 2 if state == 48 // Midwest (Wisconsin)
replace region = 3 if state == 1 // South (Alabama)
replace region = 3 if state == 3 // South (Arkansas)
replace region = 3 if state == 7 // South (Delaware)
replace region = 3 if state == 8 // South (District of Columbia)
replace region = 3 if state == 9 // South (Florida)
replace region = 3 if state == 10 // South (Georgia)
replace region = 3 if state == 16 // South (Kentucky)
replace region = 3 if state == 17 // South (Louisiana)
replace region = 3 if state == 19 // South (Maryland)
replace region = 3 if state == 23 // South (Mississippi)
replace region = 3 if state == 32 // South (North Carolina)
replace region = 3 if state == 35 // South (Oklahoma)
replace region = 3 if state == 39 // South (South Carolina)
replace region = 3 if state == 41 // South (Tennessee)
replace region = 3 if state == 42 // South (Texas)
replace region = 3 if state == 45 // South (Virginia)
replace region = 3 if state == 47 // South (West Virginia)
replace region = 4 if state == 51 // West (Alaska)
replace region = 4 if state == 2 // West (Arizona)
replace region = 4 if state == 4 // West (California)
replace region = 4 if state == 5 // West (Colorado)
replace region = 4 if state == 52 // West (Hawaii)
replace region = 4 if state == 11 // West (Idaho)
replace region = 4 if state == 25 // West (Montana)
replace region = 4 if state == 27 // West (Nevada)
replace region = 4 if state == 30 // West (New Mexico)
replace region = 4 if state == 36 // West (Oregon)
replace region = 4 if state == 43 // West (Utah)
replace region = 4 if state == 46 // West (Washington)
replace region = 4 if state == 49 // West (Wyoming)
}
label define region 1 "NE" 2 "MW" 3 "S" 4 "W"
label values region region
label var region "D: Region of residence"
drop state

*************
* Save data *
*************

local vars rid wave starttime axn5 axn3 shamed attn_passed pid3 pid7 hc2 ff2 ///
   a_overall a_overall2 male white black age ed4 region
order `vars'	
compress
save ../Output/prepped_wave1and2, replace